package subpages;

import java.util.List;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JSeparator;

import model.QA;

/**
 * This panel is a large and mostly long panel that lists all the responses in
 * the passed list.
 * 
 * @author Robert
 *
 */
public class LibraryListPanel extends JPanel {

	/**
	 * The spacing between elements in pixels.
	 */
	private static final int VERTICAL_SPACING = 20;

	/**
	 * Creates and populates the panel with a individual panel for each response
	 * in the passed list.
	 * 
	 * @param display
	 *            the list of responses to display
	 */
	public LibraryListPanel(final List<QA> display) {
		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		add(Box.createVerticalStrut(VERTICAL_SPACING));
		add(new JSeparator());
		add(Box.createVerticalStrut(VERTICAL_SPACING));
		for (QA response : display) {
			final QALibraryPanel responsePanel = new QALibraryPanel(response);
			add(responsePanel);
			add(Box.createVerticalStrut(VERTICAL_SPACING));
			add(new JSeparator());
			add(Box.createVerticalStrut(VERTICAL_SPACING));
		}

	}

}
